
'--------------------------------------------------------
' 执行所有测试用例
'--------------------------------------------------------
Public Sub test_all_case()
    ' strToTimestamp 测试
    test_strToTimestamp
    ' strToTime 测试
    test_strToTime
    ' strToDate 测试
    test_strToDate
    ' yyyyMMddStrAdd 测试
    test_yyyyMMddStrAdd
    ' yyyyMMdStrToDate 测试
    test_yyyyMMdStrToDate
End Sub

'--------------------------------------------------------
' 各方法测试
'--------------------------------------------------------
' strToTimestamp 测试
Private Sub test_strToTimestamp()
    Dim t As Date

    t = UtilsDate.strToTimestamp("20230630112233")
    Debug.Assert typeName(t) = "Date"
    Debug.Assert Format(t, "yyyymmdd hhmmss") = "20230630 112233"

    t = UtilsDate.strToTimestamp("20230630 112233")
    Debug.Assert typeName(t) = "Date"
    Debug.Assert Format(t, "yyyymmdd hhmmss") = "20230630 112233"
End Sub

' strToTime 测试
Private Sub test_strToTime()
    Dim x As Variant
    x = UtilsDate.strToTime("20230630112233")
    Debug.Assert IsEmpty(x)

    Dim t As Date
    t = UtilsDate.strToTime("112233")
    Debug.Assert typeName(t) = "Date"
    Debug.Assert Format(t, "hhmmss") = "112233"
End Sub

' strToDate 测试
Private Sub test_strToDate()
    Dim x As Variant
    x = UtilsDate.strToDate("20230630112233")
    Debug.Assert IsEmpty(x)

    Dim t As Date
    t = UtilsDate.strToDate("20230630")
    Debug.Assert typeName(t) = "Date"
    Debug.Assert Format(t, "yyyymmdd") = "20230630"
End Sub

' yyyyMMddStrAdd 测试
Private Sub test_yyyyMMddStrAdd()
    Debug.Assert UtilsDate.yyyyMMddStrAdd("20220102", 2) = "20220104"
    Debug.Assert UtilsDate.yyyyMMddStrAdd("20220102", -2) = "20211231"
    Debug.Assert UtilsDate.yyyyMMddStrAdd("20220102", 0) = "20220102"
End Sub

' yyyyMMdStrToDate 测试
Private Sub test_yyyyMMdStrToDate()
    Dim a As Date
    a = UtilsDate.yyyyMMdStrToDate("20220101")
    Debug.Assert Format(a, "yyyymmdd") = "20220101"
End Sub